<template>
  <!-- 图表必须给宽和高 -->
  <div ref="radar" class="radar-echarts" style="width:600px; height:400px">
    <p>雷达图组件Echarts</p>
  </div>
</template>

<script>
// 按需引入echarts
const echarts = require('echarts/lib/echarts') // 引入echarts主模块
require('echarts/lib/chart/radar') // 引入雷达图
// 引入提示框和标题组件
require('echarts/lib/component/title')
require('echarts/lib/component/legend')
export default {
  name: 'RandarIndex',
  created() {
    // this.$nextTick(() => {
    //   console.log(this.$refs.radar) // 实测 created 中获取不到DOM 如果使用$nextTick方法可以获取到
    // })
  },
  mounted() {
    // console.log(this.$refs.radar)
    var myChart = echarts.init(this.$refs.radar)
    var option = {
      title: {
        text: '基础雷达图'
      },
      // tooltip: {},
      legend: {
        data: ['预算分配（Allocated Budget）', '实际开销（Actual Spending）']
      },
      radar: {
        // shape: 'circle',
        axisName: {
          textStyle: {
            color: '#fff',
            backgroundColor: '#999',
            borderRadius: 3,
            padding: [3, 5]
          }
        },
        // 每个区域的最高值
        indicator: [
          { name: '工作效率', max: 100 },
          { name: '考勤', max: 100 },
          { name: '积极性', max: 100 },
          { name: '帮助同事', max: 100 },
          { name: '自主学习', max: 100 },
          { name: '正确率', max: 100 }
        ]
      },
      series: [{
        name: '预算 vs 开销（Budget vs spending）',
        type: 'radar',
        // areaStyle: {normal: {}},
        data: [
          {
            value: [10, 1, 100, 5, 100, 0],
            name: '预算分配（Allocated Budget）'
          },
          {
            value: [50, 50, 50, 50, 50, 10],
            name: '实际开销（Actual Spending）'
          }
        ]
      }]
    }
    option && myChart.setOption(option)
  }
}
</script>

<style scoped lang="less">

</style>
